22. Exercise: Networking
Exercise: Networking
INSTRUCTOR NOTE:
In this video, the first TODO incorrectly lists readInputStream; we apologize for the error.
Networking
In this Exercise, you will get to apply what you've learned on Sunshine to add an async task and permissions to load weather data.
Exercise Code
Exercise:S02.01-Exercise-Networking
Quiz: Networking
SOLUTION:
- Fill in buildUrl in NetworkUtils.java
- Add the Internet Permission
- Delete the dummy data-related code
- Create a FetchWeatherTask AsyncTask to perform the network requests
- Override the doInBackground and onPostExecute methods to get and display the results of the network request
- Create a loadWeatherData function to get the preferredWeatherLocation from SunshinePreferences and execute the FetchWeatherTask
- Call loadWeatherData from onCreate